<!doctype html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/login.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script src="./js/jquery.min.js"></script>
    <script src="./js/jquery.cookie.js"></script>
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script src="./js/base.js"></script>
    <script src="./js/e.js"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        body {
            background: url(./images/bg.jpg) no-repeat !important;
            background-size: 100% 100% !important;
        }

        .layui-form-radio {
            margin: 0 !important;
            padding: 0 !important;
            color: #3DB6FE !important;
        }

        .layui-form-checked[lay-skin=primary] i {
            background: #3DB6FE !important;
        }

        .layui-form-checkbox[lay-skin=primary]:hover i {
            border-color: #3DB6FE !important;
        }
    </style>
</head>

<body class="login-bg">

    <div class="login layui-anim layui-anim-up">
        <div class="message">OA登录</div>
        <div id="darkbannerwrap"></div>

        <form method="post" class="layui-form">
            <div style="position: relative;">
                <i class="layui-icon"
                    style="position: absolute;left:10px;line-height:50px;font-size:24px;color:#3DB6FE;">&#xe66f;</i>
                <input name="adminName" id="user_name" placeholder="请输入用户名" style="text-indent:24px" maxlength="11"
                    type="text" autocomplete="off" lay-verify="required" class="layui-input">
            </div>
            <hr class="hr15">
            <div style="position: relative;">
                <i style="position: absolute;left:10px;line-height:50px;font-size:24px;color:#3DB6FE;"
                    class="layui-icon">&#xe673;</i>
                <input name="password" id="pass" style="text-indent:24px" lay-verify="required" placeholder="请输入密码"
                    autocomplete="off" type="password" class="layui-input">
            </div>
            <hr class="hr15">
            <div style="text-align: right">
                <!-- 记住用户名复选框 -->
                <input type="checkbox" name="remember_user" id="remember_user" lay-skin="primary" title="记住密码" />
            </div>
            <hr class="hr15">
            <input value="登录" lay-submit lay-filter="login" style="width:100%;background-color: #3DB6FE!important;"
                type="submit">
            <!--            <a href="#" style="top: 10px;position: relative;color: #3DB6FE;font-size: 14px;float: right;">忘记密码？</a>-->
            <!-- <a href="register.html"
                style="top: 10px;position: relative;color: #3DB6FE;font-size: 14px;float: right;margin-right: 9px;">注册新用户</a> -->

            <hr class="hr15">
        </form>
    </div>
    <script>
        $(function () {
            var base64 = new Base64();
            // 检测是否记住密码

            if ($.cookie("remember")) {
                $("#remember_user").attr("checked", true)
                $("#user_name").val(base64.decode($.cookie("userCount")))
                $("#pass").val(base64.decode($.cookie("code")))

                // console.log(base64.decode($.cookie("code")))

            } else {
                $("#remember_user").attr("checked", false)
            }

            layui.use('form', function () {
                localStorage.setItem('isTost', 0) //默认没有改过；

                // if(localStorage.getItem('isTost') == 1){ //已经改了
                //     // console.log('已经改了')
                // }else{ //请求接口
                //     $.ajax({
                //         url: LL_upPwdTost,
                //         dataType: 'json',
                //         type: 'get',
                //         success: function (res) {
                //             //seccess？href跳转：alert(msg)\
                //             console.log(res,'是否修改密码')
                //             // if(res.msg == 0){
                //                 if(res.state == 2){
                //                     layer.confirm("前往修改初始密码",{
                //                         btn: ['确定', '取消']
                //                     }, function (index) {
                //                         layer.close(index);
                //                         layer.open({
                //                             type: 2,
                //                             content: './page/changePassWord.html',
                //                             area: ["500px", "450px"],
                //                             title: "修改密码",
                //                             // btn: ['确认', '取消'],//开启显示按钮功能
                //                             // btnAlign: 'c',//居中显示按钮
                //                             // shade:true,
                //                             shadeClose: true, //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
                //                         });
                //                         localStorage.setItem('isTost',1)
                //                     }, function(index){
                //                         localStorage.setItem('isTost',1)
                //                     });
                //                 }else{
                //                     localStorage.setItem('isTost',1)
                //                 }
                //             // }else{
                //             //     layer.alert(res.msg, {
                //             //         title: '提示'
                //             //     })
                //             // }
                //         },
                //         error: function (error) {
                //             console.log(error)
                //         }
                //     })
                // }
                var form = layui.form;
                // layer.msg('玩命卖萌中', function(){
                //   //关闭后的操作
                //   });
                //监听提交
                form.on('submit(login)', function (data) {
                    // alert(888)
                    console.log(data.field) //输出提交的信息
                    // 监听登陆按钮，发送请求处理登陆
                    // 选择了记住密码复选框之后的操作
                    if (data.field.remember_user == "on") {
                        // 存储cookie
                        $.cookie("remember", true, {
                            expires: 7
                        })
                        $.cookie("userCount", base64.encode(data.field.adminName), {
                            expires: 7
                        })
                        $.cookie("code", base64.encode(data.field.password), {
                            expires: 7
                        })
                    }


                    $.ajax({
                        url: LOGIN,
                        data: {
                            adminName: data.field.adminName,
                            password: data.field.password
                        },
                        dataType: 'json',
                        type: 'get',
                        success: function (res) {
                            //seccess？href跳转：alert(msg)\
                            console.log(res)

                            if (res.msg == "0") {
                                location.href = "index.html";
                            } else {
                                layer.msg('登录名或密码错误');
                            }
                        },
                        error: function (error) {
                            console.log(error)
                        }
                    })
                    return false;
                });

                form.verify({
                    // pass:function(){
                    //     var reg = /^[\w]{6,12}$/;
                    //     if (!($('#pass').val().match(reg))) {
                    //         //layer.msg('请输入合法密码');
                    //         layer.msg('请输入合法密码');
                    //     }
                    // }
                })
            });
        })
    </script>
</body>

</html>